<?php ob_start();
include("header.php");
validate_user();
//Submit Url///////////////////////////////////////////////////////////
if(isset($_POST['type'])&&($_POST['type']!='')){  //print_r($_POST);die();
	if($_POST['type']=='url'){ 
		$sql=mysql_query("INSERT INTO `my_url` SET `url`='".$_POST['page_url']."',
													`height`='".$_POST['height']."',
													`user_id`='".$_SESSION['id']."',
													`url_id`='".$_SESSION['url_id']."',
													`status` = 0 ")or die(mysql_error());
		if($sql){
			header("location:create_page_step2.php"); exit;
		}
	}else{ //print_r($_POST);print_r($_FILES);
		$base_name = basename($_FILES['photo']['name']);
		$photos='';
		if($base_name!="" && $_FILES['photo']['error']==0 && $_FILES['photo']['size']<(1024*1024)){
			$path="uploads/";
			$thumb_folder_path = "uploads/thumb/";
			$tt=time();
			$target_path=$path.$tt.$base_name;
			$thumb_target_path = $thumb_folder_path."t_".$tt.$base_name;
			$photo=$tt.$base_name;
			$photos =" `photo` = '".$photo."', "; 
			if(move_uploaded_file($_FILES['photo']['tmp_name'],$target_path)){
				$image = new SimpleImage();
				$image->load($target_path);
				$image->resize(100,100);
				$image->save($thumb_target_path);
			}
		}
		$sql=mysql_query("INSERT INTO `my_url` SET $photos `user_id`='".$_SESSION['id']."',
													`url_id`='".$_SESSION['url_id']."',
													`status` = 0 ")or die(mysql_error());
		if($sql){
			header("location:create_page_step2.php"); exit;
		}
	}
}

/////////////////////////////////////////////////////////////
if(isset($_SESSION['url_id'])){ $url=get_allitem('my_business_url','id',$_SESSION['url_id']); }

?>

<!--Body Section start-->
<div class="body_div" style="margin: 0 auto; float:none;">
<div class="create_page_head">

<div id="url">
    <h1><span>http://www.mycitydial.com/<?php if(isset($url['url'])){ echo cut_text($url['url'],75);} ?></span>
     <input type="text" class="long_box" value="<?php if(isset($url['url'])){ echo cut_text($url['url'],75);} ?>" style="width:400px" />
    </h1>
    <input type="hidden" id="urlid" value="<?php if(isset($url['id'])){ echo $url['id'];} ?>" />
    <a href="javascript:;" id="urledit">+Edit</a><span id='msg' style='color:red;'></span>
</div> 
 </div>


<!--Create page Steps div start-->
<div class="steps_div">
<div class="steps">
 
 
 <ul>
<li><a href="#" class="active">
<div>
<img src="images/steps/1_black.png" />
<img src="images/steps/1.png" />
<span>Home Page</span>
</div>
</a></li>

<li><a href="#"  >
<div>
<img src="images/steps/02.png" />
<img src="images/steps/2.png" />
<span>Page Gallery</span>
</div>
</a></li>

<li><a href="#">
<div>
<img src="images/steps/03.png" />
<img src="images/steps/3.png" />
<span>About Page</span>
</div>
</a></li>

<li><a href="#">
<div>
<img src="images/steps/4_black.png" />
<img src="images/steps/4.png" />
<span>Owner Profile </span>
</div>
</a></li>
</ul>
</div>
<ul id="output2">
<li>
<div class="header_navi"> 
  <h2> Select your Home page Type    </h2>
  <div class="labelradio">   <label>  <input type="radio"  checked="checked" name="urltype" /> Url</label> <label> <input type="radio"    name="urltype" /> Photo </label>     </div>
  <div class="btn"> 
    <div class="nextprev">
     <a href="javascript:;" class="inactive" ><img src="images/prev.png"  /></a>
<a href="create_page_step2.php"><img src="images/next.png"  /></a>     
    </div>
  <!--  <div class="nextstep"><a href="create_page_step2.php" class="inputbtn" id="fanpage1">Save and Next</a></div>-->
    <div class="nextstep"><a href="javascript:;" class="inputbtn" id="fanpage1">Save and Next</a></div>
    
  </div>
  
</div>


<div class="setps_form_heading">




<?php if(isset($_SESSION['url_id'])){ $url=get_allitem('my_url','url_id',$_SESSION['url_id'],'url'); } ?>
<form action="" method="post" id="fanpage" class="cpage" >
 <div class="add_url">
 <span>Host Your Page URL</span>
 <input name="page_url" type="text" id="page_url" class="add_url_box" value="<?php if(!empty($url['url'])){ echo $url['url'];} ?>"   placeholder="http://www.yoursitename.com/fanpage.html  (example)"  /> 
 </div>
 
 
 
   <div class="add_url_width">
 <span>Height</span>
 
 <input name="height" type="text" id="height" class="width_box" value="<?php if(!empty($url['height'])){ echo $url['height']; }else{ echo "750"; } ?>" required="required" />
 </div>
  <input type="hidden" name="type" value="url" />
</form>


<form action="" method="post" id="fanpage2" class="cpage" style="display:none" enctype="multipart/form-data" >
 <div class="add_url">
 <span>Upload Home Page Photo</span>
 <input name="photourl" type="text" id="page_url" class="add_url_box" value="<?php if(!empty($url['url'])){ echo $url['url'];} ?>"   placeholder="http://www.yoursitename.com/fanpage.html  (example)"  /> 
 </div>
 
 
 
 
<div class="add_url_width urlupload">
    <span><input type="file" name="photo"  style="visibility:hidden ; height:20px; " onchange="readURL(this);"  /></span>
    <a href="javascript:;" class="inputbtn" >Upload</a>    
</div>
<input type="hidden" name="type" value="photo" /> 
</form>




</div>

 <div class="artical">
 <iframe id="myiframe" src="<?php //echo $url['page_url']; ?>" height="<?php //echo $url['page_height']; ?>" width="750" scrolling="no"></iframe>
 <img id="myimage" src="" height="100%" width="750" />
 </div>
</li>





<!--.......................-->

</ul>
</div>
<!--Create page Steps div end-->
<br clear="all" />
<br clear="all" />
</div>
<? include("footer.php");  ?>

